﻿using DataEntity.Entities;
using IService;
using Microsoft.EntityFrameworkCore;
using Model.UserDTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Service
{
   public class UserService:IUserService
    {
        #region 构造函数依赖注入
        private readonly DbContext _dbContext;
        public UserService(DbContext dbContext)
        {
            _dbContext = dbContext;
        }
        #endregion
        public List<UserOutput> GetUserInfo(string userName)
        {
            return (from a in _dbContext.Set<Userinfo>().Where(u => u.UserName == userName)
                    select new UserOutput
                    {
                        UserId = a.UserId,
                        UserEmail = a.UserEmail,
                        UserEnable = a.UserEnable,
                        UserMember = a.UserMember,
                        UserName = a.UserName,
                        IsOwner = (bool)a.IsOwner
                    }).ToList();
        }
    }
}
